#pragma once

#include <string>
#include <vector>
#include <list>
using namespace std;

#include "Tileset.hpp"
#include "..\Entity\Entity.hpp"
#include "Portal.hpp"

/*
\class Map
\brief Contains what we need to manage the map in the game.
\date Mar. 15th 2013
\version 0.1
*/
class Map
{
public:
	~Map();
	/*
	\brief Load the map. Reload if needed.
	\param path The path to the map we want to load.
	*/
	void loadMap(string path);
	/*
	\brief Load the first test map. Early-alpha.
	*/
	void loadMap1();
	/*
	\brief Load the second test map. Early-alpha.
	*/
	void loadMap2();
	/*
	\brief Load the thrid test map. Early-alpha.
	*/
	void loadMap3();
	/*
	\brief Check either an entity is entering a portal or not.
	\param entity The entity to check
	\param nextMap Out Parameter, returns the map number where it will land
	\param destination Out Parameter, returns the position of the Entity after warping
	\return true if going through a portal, false else
	*/
	bool changeMap(Entity* entity, unsigned int& nextMap, sf::Vector2f& destination);
	/*
	\brief Draw the map, for early-alpha.
	*/
	void draw(sf::RenderWindow& window);

	/*
	\brief Verify that the position is possible according to the map.
	\param The entity to check.
	*/
	void bruteLoad(string pathToMapping, string pathToTileset, string pathToCollisionMask, 
		unsigned int width, unsigned int height);

	/*
	\brief Verify that the position is possible according to the map.
	\param The entity to check.
	*/
	void checkEntityPosition(Entity& ent);

	float width() const;
	float height() const;

private:
	unsigned int m_width;
	unsigned int m_height;
	vector<unsigned int> m_mapping;
	list<Portal*> m_portals;
	Tileset m_tileset;
};
